package com.phei.netty.broadcast;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class LogEventHandle extends SimpleChannelInboundHandler<LogEvent> {

	@Override
	protected void channelRead0(ChannelHandlerContext arg0, LogEvent event) throws Exception {
		StringBuilder builder = new StringBuilder();
		builder.append(event.getReceived());
		builder.append("[");
		builder.append(event.getAddress().toString());
		builder.append("][");
		builder.append(event.getLogfile());
		builder.append("]:");
		builder.append(event.getMsg());
		System.out.println(builder.toString());
	}

	@Override
	public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
		cause.printStackTrace();
		ctx.close();
	}


}
